package com.tianyu.sports.dao;

import com.tianyu.sports.po.Vipinfo;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

/**
 *
 * VIP数据Dao接口
 *
 */
public interface VipinfoMapper {

    /**
     * 根据ID删除Vip数据
     *
     * @param id
     * @return
     */
    int deleteByPrimaryKey(Integer id);

    /**
     *
     * 添加Vip数据
     *
     * @param record
     * @return
     */
    int insert(Vipinfo record);

    /**
     * 根据条件添加Vip数据
     *
     * @param record
     * @return
     */
    int insertSelective(Vipinfo record);

    /**
     * 根据ID查询VIP数据
     *
     * @param id
     * @return
     */
    Vipinfo selectByPrimaryKey(Integer id);

    /**
     * 动态更新VIP数据
     *
     * @param record
     * @return
     */
    int updateByPrimaryKeySelective(Vipinfo record);

    /**
     * 更新VIP数据根据ID
     *
     * @param record
     * @return
     */
    int updateByPrimaryKey(Vipinfo record);

    /**
     * 插入VIP数据信息
     *
     * @param record
     * @return
     */
    int insertVipInfo(Vipinfo record);

    /**
     * 获取当前VIP注册总数
     *
     * @return
     */
    @Select("SELECT num FROM vipnum ")
    int getVipNum();

    /**
     *
     * 根据手机号后去VIPid
     *
     * @param phone
     * @return
     */
    @Select("SELECT ID FROM vipinfo WHERE PHONE = #{phone}")
    int selectByPhone(@Param("phone") String phone);

    /**
     * 根据身份证号获取ID
     *
     * @param idNumber
     * @return
     */
    @Select("SELECT ID FROM vipinfo WHERE IDnumber = #{idNumber}")
    int checkIDNumber(@Param("idNumber") String idNumber);

    /**
     * 更新注册总数++
     *
     * @return
     */
    @Update("UPDATE vipnum SET num = num+1 WHERE id = 1 ")
    int updateVipnum();

    /**
     * 设置VIP注册总数
     *
     * @param num
     * @return
     */
    @Update("UPDATE vipnum SET num = #{num} WHERE id = 1 ")
    int updateVipnumByOrder(int num);

    /**
     * 根据ID 查询VIP注册历史
     *
     * @param id
     * @return
     */
    @Select("SELECT username,phone,email,address,idnumber,creattime FROM vipinfohistory WHERE id = #{id}")
    Vipinfo selectVipInfoHistory(@Param("id") Integer id);
}